<?php
require('qs_connection.php');
require_once('employment_source_data_users.php');
require_once('qs_functions.php');
$err_string = "";
@session_start();
@ob_start();
if (isset($_POST["act"])) {
    $userlevel = 0;
    $sql = "";
$sql .= "  SELECT `username` , `password` , `level` , `email` FROM `people`\n";
    $sql .= " WHERE ";
    $sql .= " `username` = '".qsrequest("User"). "'" ;
    $sql .= " AND `password` = '" .qsrequest("Password"). "'";
if(!$result = @mysql_query($sql)){
    $err_string .= "<strong>Error:</strong> while connecting to database<br>" . mysql_error();
}else{
    $num_rows = mysql_num_rows($result);
    $row = mysql_fetch_array($result);
}
if ($err_string != "") {
    print "<Center><Table Border=\"0\" Cellspacing=\"1\" bgcolor=\"#CCCCCC\" >";
    print "<tr>";
    print "<td height=\"80\" align=\"Default\" bgcolor=\"#FFFFFF\">";
    print "<font color=\"#000099\" size=\"2\">";
    print $err_string;
    print "</font>";
    print "</td>";
    print "</tr>";
    print "</Table></Center>";
    exit;
}
    if ($num_rows >0) {
        $userlevel = $row[2];
    }
    if ($result > 0) {mysql_free_result($result);}
    if ($userlevel > 0) {
        $_SESSION["Logon"] = "TRUE";
        $_SESSION["UserLogon"] = qsrequest("User");
        $_SESSION["UserLevel"] = $userlevel;
        $RedirectURL = qssession("RedirectURL");
#----get submit url page----
    $submiturl = "./global_group.php?";
        if ($RedirectURL == "") {
          $RedirectURL = $submiturl;
        }
        if (qssession("firstredirecturl") == "") {
          $_SESSION["firstredirecturl"] = $RedirectURL;
        }
        header ("Location: $RedirectURL");
        @ob_end_flush();
        exit;
    } else {
        $err_string = "Login failed";
    }
} else{
    if ((qssession("UserLogon") != "") && (qssession("Logon") == "FALSE")) {
        $err_string = "Permission failed";
    }
}
?>
<HTML>
<HEAD>
<Title>Login settings</Title>
<link rel="stylesheet" type="text/css" href="employment_source_data_login.css">
<meta name="generator" content="dbQwikSite Ecommerce">
</HEAD>
<BODY><script language="javascript" src="./js/qs_menu.js"></script>
<center><center><strong><font size="5">
Global Login
</font></strong></center><br>

<A NAME=top></A>
<Form name="qs_login_form" method="post" action="./global_group_login.php">
<Table Border="0" Cellpadding="2" Cellspacing="1" BgColor="#10783F">

<?php
$css_class = "\"TrOdd\"";
?>
<tr>
<td colspan="2" class="ThRows">Login settings</td>
</tr>
<?php
if ($err_string != "") {
    print "<tr>";
    print "<td class=\"ThRows\"><Strong>Error:</Strong></td>";
    print "<td class=" . $css_class . " align=Default>" . $err_string . "</td>";
    print "</tr>";
}
?>
<tr>
<td class="ThRows">Login:</td>
<td class="TrOdd" align=Default><input name="User" type="text"></td>
</tr>
<tr>
<td class="ThRows">Password:</td>
<td class="TrOdd" align=Default><input name="Password" type="password"></td>
</tr>
<tr>
<td class="ThRows">&nbsp;</td>
<td class="TrOdd" align=Default>
<input type="hidden" name="act" value="n">
<input type="submit" name="QS_Submit" value="Submit">&nbsp;&nbsp;
<input type="reset" name="Reset" value="Reset">
</td>
</tr>
</Table><br>
<A HREF="employment_source_data_password.php">Forgotten Password</A>
</Form>
<A NAME=bottom></A>
</Center>

</BODY>
</HTML>
